<template>
    <div>

        <el-tabs v-model="activeName" :stretch="true" @tab-click="handleClick">
            <el-tab-pane label="医生工作量统计列表" name="workload">
                <!-- 查询条件开始 -->
                <el-form ref="queryWorkloadFrom" :model="queryWorkloadParams" :inline="true" label-width="68px">
                    <el-form-item label="医生名称" prop="doctorName">
                        <el-input v-model="queryWorkloadParams.doctorName" placeholder="请输入医生名称" clearable size="small"
                                  style="width:180px"/>
                    </el-form-item>
                    <el-form-item label="接诊时间">
                        <el-date-picker v-model="queryWorkloadParams.dateRange" size="small" style="width:320px"
                                        value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期(默认今天)"
                                        end-placeholder="结束日期(默认今天)"/>
                    </el-form-item>
                    <el-form-item>
                        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleWorkloadQuery">搜索
                        </el-button>
                        <el-button type="primary" icon="el-icon-refresh" size="mini" @click="resetWorkloadQuery">重置
                        </el-button>
                    </el-form-item>
                </el-form>
                <!-- 查询条件结束 -->
                <!-- 数据表格开始 -->
                <el-table v-loading="loading" border :data="workloadList" show-summary>
                    <el-table-column label="挂号ID" prop="registrationId" align="center"/>
                    <el-table-column label="医生编号" prop="userId" align="center"/>
                    <el-table-column label="医生姓名" prop="doctorName" align="center"/>
                    <el-table-column label="挂号费用" prop="registrationAmount" align="center"/>
                    <el-table-column label="患者姓名" prop="patientName" align="center"/>
                    <el-table-column label="就诊时间" prop="visitDate" align="center"/>
                </el-table>
                <!-- 数据结束结束 -->

            </el-tab-pane>
            <el-tab-pane label="总体工作量统计列表" name="workloadStat">
                <!-- 查询条件开始 -->
                <el-form ref="queryWorkloadStatFrom" :model="queryWorkloadStatParams" :inline="true" label-width="68px">
                    <el-form-item label="医生姓名" prop="doctorName">
                        <el-input v-model="queryWorkloadStatParams.doctorName" placeholder="请输入医生姓名" clearable
                                  size="small" style="width:180px"/>
                    </el-form-item>
                    <el-form-item label="接诊时间">
                        <el-date-picker v-model="queryWorkloadStatParams.dateRange" size="small" style="width:320px"
                                        value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期(默认今天)"
                                        end-placeholder="结束日期(默认今天)"/>
                    </el-form-item>
                    <el-form-item>
                        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleWorkloadStatQuery">搜索
                        </el-button>
                        <el-button type="primary" icon="el-icon-refresh" size="mini" @click="resetWorkloadStatQuery">重置
                        </el-button>
                    </el-form-item>
                </el-form>
                <!-- 查询条件结束 -->
                <!-- 数据表格开始 -->
                <el-table v-loading="loading" border :data="workloadStatList" show-summary>
                    <el-table-column label="医生编号" prop="userId" align="center"/>
                    <el-table-column label="医生姓名" prop="doctorName" align="center"/>
                    <el-table-column label="挂号总金额" prop="totalAmount" align="center"/>
                    <el-table-column label="接诊数量" prop="count" align="center"/>
                </el-table>
                <!-- 数据结束结束 -->
            </el-tab-pane>
        </el-tabs>
    </div>
</template>

<script>
    export default {
        name: "workload",
        data() {
            return {
                // 遮罩
                loading: false,
                // 被激活的tab名称
                activeName: 'workload',
                // 医生工作量统计列表数据
                workloadList: [],
                // 总体工作量统计列表数据
                workloadStatList: [],
                // 医生工作量统计列表查询参数
                queryWorkloadParams: {},
                // 总体工作量统计列表查询参数
                queryWorkloadStatParams: {}
            }
        },
        created() {
            // 默认查询工作量列表
            this.listWorkload()
        },
        methods: {
            // 点击tab事件
            handleClick() {
                //console.log(this.activeName)
                if (this.activeName === 'workload') {
                    this.listWorkload()
                } else {
                    this.listWorkloadStat()
                }
            },
            // 查询医生工作量统计列表
            listWorkload() {
                this.loading = true
                this.$axios.post("statistics/api/registration/queryAll", this.queryWorkloadParams).then(res => {
                    this.workloadList = res.data.data;
                    this.loading = false
                }).catch(() => {
                    this.msgError('查询失败')
                    this.loading = false
                })
            },
            // 查询医生工作量统计列表
            handleWorkloadQuery() {
                this.listWorkload()
            },
            // 重置医生工作量统计列表
            resetWorkloadQuery() {
                this.queryWorkloadParams = {}
                this.listWorkload()
            },
            // 查询总体工作量统计列表
            listWorkloadStat() {
                this.loading = true
                this.$axios.post("statistics/api/registration/querySata", this.queryWorkloadStatParams).then(res => {
                    this.workloadStatList = res.data.data;
                    this.loading = false
                }).catch(() => {
                    this.msgError('查询失败')
                    this.loading = false
                })
            },
            // 查询总体工作量统计列表
            handleWorkloadStatQuery() {
                this.listWorkloadStat()
            },
            // 重置总体工作量统计列表
            resetWorkloadStatQuery() {
                this.queryWorkloadStatParams={}
                this.listWorkloadStat()
            }
        }
    }
</script>

<style scoped>

</style>
